Josephus Problem Algorithm